package local.blueheart.java8;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class TestFor {

    public static void main(String[] args){
        List<Integer> list = Arrays.asList(1,2,3,4,5,6,7,8,9);
        System.out.println("=========1.5以前传统方法=========");
        for(int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }

        System.out.println("========1.5for增强==============");
        for (Integer integer:list){
            System.out.println(integer);
        }

        System.out.println("========1.8函数接口=============");
        list.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });

        System.out.println("========1.8Lamdba=============");
        list.forEach(integer -> System.out.println(integer));

        System.out.println("========1.8方法引用=============");
        list.forEach(System.out::println);
    }

}
